package com.sc;

import com.sc.configs.SysSettings;
import com.sc.listener.MainBusListener;
import com.sc.tasks.HKCameraTask;
import com.sc.tasks.HeartBeatTask;
import com.sc.utils.ApplicationContextUtil;
import com.sc.utils.DtoUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.TimeZone;

@SpringBootApplication
public class InfoComAdapterApplication {

    public static void main(String[] args) {
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
        SpringApplication application = new SpringApplication(InfoComAdapterApplication.class);
        application.addListeners(new MainBusListener());

        application.run(args);

        var heartBeatTask = (HeartBeatTask) ApplicationContextUtil.getBean(HeartBeatTask.class);

        var settings = (SysSettings) ApplicationContextUtil.getBean(SysSettings.class);
        var adapterDto = DtoUtils.getAdapterDto(settings);
        heartBeatTask.init(adapterDto, settings.getHeartBeatUrl());

        heartBeatTask.start();

        var hkTask = (HKCameraTask) ApplicationContextUtil.getBean(HKCameraTask.class);
        hkTask.start();

    }

}
